package com.dongdongshop.service.impl;


import com.dongdongshop.domain.req.SellerReq;
import com.dongdongshop.domain.res.SellerRes;
import com.dongdongshop.model.Seller;
import com.dongdongshop.service.SellerService;
import com.dongdongshop.mapper.SellerMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author 13412
* @description 针对表【tb_seller(商家表)】的数据库操作Service实现
* @createDate 2024-09-02 22:01:08
*/
@Service
public class SellerServiceImpl implements SellerService {
    @Autowired
    private SellerMapper sellerMapper;

    @Override
    public SellerRes getSellerInfo(String sellerId) {
       Seller seller= sellerMapper.getSellerInfo(sellerId);
       if(seller!=null){
           SellerRes sellerRes = new SellerRes();
           BeanUtils.copyProperties(seller,sellerRes);
           return sellerRes;
       }
       return new SellerRes();
    }

    @Override
    public List<SellerRes> queryAudits() {
        List<Seller> seller=sellerMapper.queryAudits();
        return seller.stream().map(s->{
            SellerRes sellerRes = new SellerRes();
            BeanUtils.copyProperties(s,sellerRes);
            return sellerRes;
        }).collect(Collectors.toList());
    }

    @Override
    public void updateStatus(SellerReq sellerReq) {
        sellerMapper.updateStatus(sellerReq);
    }
}




